package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class GetUsedSpaceFileStores {
	public static void main(String[] args) {
		FileSystem fs = FileSystems.getDefault();
		for (FileStore store : fs.getFileStores()) {
			try {
				long used_space = (store.getTotalSpace() - store.getUnallocatedSpace()) / 1024;

				System.out.println("--- " + store.name() + " --- " + store.type());
				System.out.println("已用空间: " + used_space);
			} catch (IOException e) {
				System.err.println(e);
			}
		}
	}
}
